<!DOCTYPE html>
<!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!-->
<html lang="en">
<!--<![endif]-->

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <meta name="keywords" content="">

    <title>Semaphores</title>

    {% load static %}
    <link rel="stylesheet" type="text/css" href="{%static 'wikipages/fonts/font-awesome-4.3.0/css/font-awesome.min.css' %}">
    <link rel="stylesheet" type="text/css" href="{%static 'wikipages/css/stroke.css' %}">
    <link rel="stylesheet" type="text/css" href="{%static 'wikipages/css/bootstrap.css' %}">
    <link rel="stylesheet" type="text/css" href="{%static 'wikipages/css/animate.css' %}">
    <link rel="stylesheet" type="text/css" href="{%static 'wikipages/css/prettyPhoto.css' %}">
    <link rel="stylesheet" type="text/css" href="{%static 'wikipages/css/style.css' %}">
    <link rel="stylesheet" type="text/css" href="{%static 'wikipages/js/syntax-highlighter/styles/shCore.css' %}" media="all">
    <link rel="stylesheet" type="text/css" href="{%static 'wikipages/js/syntax-highlighter/styles/shThemeRDark.css' %}" media="all">
    <link rel="stylesheet" type="text/css" href="{%static 'wikipages/css/custom.css' %}">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>

<body>

    <div id="wrapper">

        <div class="container">

            <section id="top" class="section docs-heading">

                <div class="row">
                    <div class="col-md-12">
                        <div class="big-title text-center">
                            <h1>Process Synchronization</h1>
                        </div>
                        <!-- end title -->
                    </div>
                    <!-- end 12 -->
                </div>
                <!-- end row -->

                <hr>

            </section>
            <!-- end section -->

            <div class="row">

                <div class="col-md-3">
                    <nav class="docs-sidebar" data-spy="affix" data-offset-top="300" data-offset-bottom="200" role="navigation">
                        <ul class="nav">
                            <li><a href="#line1">Introduction</a></li>
                            <li><a href="#line2">Critical Section Problems</a>
                              <ul class="nav">
                                  <li><a href="#line2_1">Producer - Consumer Problem</a></li>
                                    <!-- <li><a href="#line2_2">Producer - Consumer Example</a></li> -->
                                  <li><a href="#line2_3">Reader - Writer Problem</a></li>
                                    <!-- <li><a href="#line2_4">Reader - Writer Example</a></li> -->
                                  <li><a href="#line2_5">Dining Philosopher’s Problem</a></li>
                                    <!-- <li><a href="#line2_6">Dining Philosopher's Example</a></li> -->
                                  <li><a href="#line2_7">Sleeping Barber Problem</a></li>
                                    <!-- <li><a href="#line2_8">Sleeping Barber Example</a></li> -->
                              </ul>
                            </li>
                          </ul>
                    </nav >
                </div>
                <div class="col-md-9">
                    <section id = "line1" class="welcome">

                        <div class="row">
                            <div class="col-md-12 left-align">
                                <h2 class="dark-text">Introduction<hr></h2>
                                <div class="row">

                                    <div class="col-md-12 full">
                                        <div class="intro1">
                                            <ul>
                                                <!-- <li><strong>Demo Page : </strong><a href="http://themeforest.net/user/surjithctly" target="_blank">Click Here</a></li> -->
                                                <li><strong>Front End Developers : </strong>Akhil Udathu</li>
                                                <li><strong>Backend End Developers : </strong>Akhil Udathu</li>
                                                <li><strong>Server Side Integration : </strong>Sagar Bharadwaj</li>
                                                <li><strong>Content : </strong>Puneet U</li>
                                            </ul>
                                        </div>

                                        <hr>
                                        <div>
                                            <p>Process Synchronization means sharing system resources by processes in a such a way that, Concurrent access to shared data is handled thereby minimizing the chance of inconsistent data. Maintaining data consistency demands mechanisms to ensure synchronized execution of cooperating processes.</p>

                                            <p>Process Synchronization was introduced to handle problems that arose while multiple process executions.</p>
                                            <p>Data Structures used for Synchronization:</p>

                                            <ol>
                                                <li>
                                                  <h4 id = "line1_1">Mutex Locks</h4>
                                                  <p>In this approach, in the entry section of code, a LOCK is acquired over the critical resources modified and used inside critical section (block of code where the shared resources are being modified ), and in the exit section that LOCK is released.</p>
                                                  <p>As the resource is locked while a process executes its critical section hence no other process can access it.</p>
                                                  </li>
                                                  <li>  <h4 id = "line1_2">Semaphores</h4>
                                                  <p>In 1965, Dijkstra proposed a new and very significant technique for managing concurrent processes by using the value of a simple integer variable to synchronize the progress of interacting processes. This integer variable is called semaphore. So it is basically a synchronizing tool and is accessed only through two low standard atomic operations, wait() and signal().
                                                  <ul>
                                                    <li><h6>Wait :</h6> decrement the value of its argument S as soon as it would become non-negative.</li>
                                                    <li><h6>Signal :</h6> increment the value of its argument, S as an individual operation.</li>
                                                </p>

                                              </li>
                                            </ol>
                                        </div>
                                    </div>
                                </div>
                                <!-- end row -->
                            </div>
                        </div>
                    <hr>
                    </section>

                    <section id="line2" class="section">

                        <div class="row">
                            <div class="col-md-12 left-align">
                                <h2 class="dark-text">Critical Section Problems<a href="#top">#back to top</a><hr></h2>
                            </div>
                            <!-- end col -->
                        </div>
                        <!-- end row -->

                        <div class="row">
                                <h4 id="line2_1">Producer – Consumer Problem</h4>
                                <p>It is also known as the bounded buffer problem. The problem consists of two processes, the producer and consumer, sharing a common buffer (fixed size). The producer’s job is to generate data and store it in the common buffer, one at a time. The consumer keeps consuming data until the common buffer empties.
                                </p>
                                <p>The producer shouldn’t be able to produce more data items when the buffer is full, and the consumer shouldn’t be able to consumer the data items when the buffer is empty.
                                </p>
                                <!-- end col -->

                        </div>
                        <!-- end row -->

                          <!-- <h4 id="line2_2">Producer Consumer Example</h4>

                        <div class="col-md-6">
                            <a href="upload/thumbnail.png" data-rel="prettyPhoto"><img src="images/upload/thumbnail.png" alt="" class="img-responsive img-thumbnail"></a>
                            <h4>Demo</h4>
                        </div> -->
                        <!-- end col -->
                        <br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <div class="row">
                                <h4 id="line2_3">Reader – Writer Problem</h4>
                                <p>This is an example of common concurrency problem. Here many threads try to access the same shared resource simultaneously. Threads may read/write (or append). Threads reading the shared resource can do it simultaneously, i.e. two or more readers are allowed to access the shared resource. If a thread is writing into the resource, no other thread can access the resource.
                                </p>
                         <!-- end col -->

                        </div>
                        <!-- end row -->

                          <!-- <h4 id="line2_4">Reader Writer Example</h4>

                        <div class="col-md-6">
                            <a href="upload/thumbnail.png" data-rel="prettyPhoto"><img src="images/upload/thumbnail.png" alt="" class="img-responsive img-thumbnail"></a>
                            <h4>Demo</h4>
                        </div> -->

                        <br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <!-- end col -->
                        <br>
                        <div class="row">
                                <h4 id="line2_5">Dining Philosopher’s Problem</h4>
                                <p>The problem consists of five philosophers sitting around a circular table. The table has five forks. At any instance, a philosopher is eating or thinking. When a philosopher wants to eat, he has to use two forks, one from his left and one from his right. When a philosopher starts thinking, he keeps the two forks on the table. So, philosopher requires the two forks(shared resource) to start eating.
                                </p>
                                <!-- end col -->
                        </div>
                        <!-- end row -->

                        <br>

                          <!-- <h4 id="line2_6">Dining Philosopher's Example</h4>

                        <div class="col-md-6">
                            <a href="upload/thumbnail.png" data-rel="prettyPhoto"><img src="images/upload/thumbnail.png" alt="" class="img-responsive img-thumbnail"></a>
                            <h4>Demo</h4>
                        </div> -->

                        <br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <br>
                        <!-- end col -->
                        <div class="row">
                                <h4 id="line2_7">Sleeping Barber Problem</h4>
                                  <p>This is an example of synchronization problem. The objective is to keeping a barber working when there are customers, resting when there are none in an orderly manner.
                                  </p>
                                 <p>The barber has one barber chair and a waiting room with a number of chairs in it. When the barber finishes cutting a customer's hair, he dismisses the customer and then goes to the waiting room to see if there are other customers waiting. If there are, he brings one of them back to the chair and cuts his hair. If there are no other customers waiting, he returns to his chair and sleeps in it.
                                 </p>
                                 <p>Each customer, when he arrives, looks to see what the barber is doing. If the barber is sleeping, then the customer wakes him up and sits in the chair. If the barber is cutting hair, then the customer goes to the waiting room. If there is a free chair in the waiting room, the customer sits in it and waits his turn. If there is no free chair, then the customer leaves.
                                 </p>

                                <!-- end col -->

                        </div>
                        <!-- end row -->

                        <br>
<!--
                          <h4 id="line2_8">Sleeping Barber Example</h4>

                        <div class="col-md-6">
                            <a href="upload/thumbnail.png" data-rel="prettyPhoto"><img src="images/upload/thumbnail.png" alt="" class="img-responsive img-thumbnail"></a>
                            <h4>Demo</h4>
                        </div> -->
                        <!-- end col -->

                    </section>
                    <!-- end section -->
                </div>
                <!-- // end .col -->

            </div>
            <!-- // end .row -->

        </div>
        <!-- // end container -->

    </div>
    <!-- end wrapper -->

    <script src="{%static 'wikipages/js/jquery.min.js' %}"></script>
    <script src="{%static 'wikipages/js/bootstrap.min.js' %}"></script>
    <script src="{%static 'wikipages/js/retina.js' %}"></script>
    <script src="{%static 'wikipages/js/jquery.fitvids.js' %}"></script>
    <script src="{%static 'wikipages/js/wow.js' %}"></script>
    <script src="{%static 'wikipages/js/jquery.prettyPhoto.js' %}"></script>
    <script src="{%static 'wikipages/js/custom.js' %}"></script>
    <script src="{%static 'wikipages/js/main.js' %}"></script>
    <script src="{%static 'wikipages/js/syntax-highlighter/scripts/shCore.js' %}"></script>
    <script src="{%static 'wikipages/js/syntax-highlighter/scripts/shBrushXml.js' %}"></script>
    <script src="{%static 'wikipages/js/syntax-highlighter/scripts/shBrushCss.js' %}"></script>
    <script src="{%static 'wikipages/js/syntax-highlighter/scripts/shBrushJScript.js' %}"></script>

</body>

</html>
